package com.le.tester.book.concurrentjavafight.l6_3_1;

import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;

/**
 * createTime：2022/10/19 16:20
 * description：错误的timer行为
 */
public class OutOfTime {

    public static void main(String[] args) throws InterruptedException {
        Timer timer = new Timer();
        timer.schedule(new ThreadTask(), 1);
        TimeUnit.SECONDS.sleep(1);
        timer.schedule(new ThreadTask(), 1);
        TimeUnit.SECONDS.sleep(5);
    }

    static class ThreadTask extends TimerTask {

        @Override
        public void run() {
            throw new RuntimeException();
        }
    }
}
